from selenium import webdriver

url = 'https://www.baidu.com'

driver = webdriver.Chrome(executable_path=r'E:\ChromeDriver\chromedriver_win32/chromedriver.exe')

driver.get(url)

print(driver.get_cookies())

# 将cookies转换为字典
cookies_dict = {cookie['name']: cookie['value'] for cookie in driver.get_cookies()}

print(cookies_dict)

# 删除cookie
# 删除一条cookie
print(driver.delete_cookie('domain'))
# 删除所有的cookie
print(driver.delete_all_cookies())
